package ro.thich.alchemy;

import android.content.*;
import android.database.sqlite.*;

public class ElementSQLiteHelper extends SQLiteOpenHelper
 {

	public ElementSQLiteHelper(Context context) {
		// Databse: todos_db, Version: 1
		super(context, "elements_db", null, 1);
	}

	/**
	 * Create simple table
	 * elemens
	 *         _id     - key
	 *         element    - todo text
	 */
	@Override
	public void onCreate(SQLiteDatabase db) {
		// Execute create table SQL
		db.execSQL("CREATE TABLE elements (_id INTEGER PRIMARY KEY AUTOINCREMENT, element TEXT NOT NULL);");
	}

	/**
	 * Recreates table
	 */
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVer, int newVer) {
		// DROP table
		db.execSQL("DROP TABLE IF EXISTS elements");
		// Recreate table
		onCreate(db);
	}
}
